package leading;

import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Enumeration;
import java.util.Properties;

public class ReadProperties {
	public static void main(String[] args) throws Exception {
		System.out.println(ReadProperties.class.getResource("ReadProperties.class"));
		//这里的当前路径是工程路径leadingsoft
/*		FileOutputStream fos = new FileOutputStream(new File("./ok.txt"),true);
		fos.write(new String("hello").getBytes());
		fos.close();*/
		File file = new File("DBType.properties");
		Properties tProperties = new Properties();
		try {
			FileInputStream tFileInputStream = new FileInputStream(file);
			//InputStream tFileInputStream = new BufferedInputStream(new FileInputStream(file));
			tProperties.load(tFileInputStream);
			tFileInputStream.close();
			Enumeration propertyName = tProperties.propertyNames();
			while(propertyName.hasMoreElements()){
				String key = (String)propertyName.nextElement();
				String value = tProperties.getProperty(key);
				System.out.println(key + ":" +value);
			}
		} catch (FileNotFoundException e) {
			e.printStackTrace();
			System.out.println("找不到该文件！！");
		}
	}
}
